//
//  PreferDetailViewController.m
//  Socrates
//
//  Created by shy on 15/4/7.
//  Copyright (c) 2015年 shy. All rights reserved.
//

#import "PreferDetailViewController.h"

#import "CircleImage.h"
#import "ImageGallery.h"
#import "RDVTabBarController.h"

typedef enum {
    kActivity_time_item = 0,
    kActivity_location_item,
    kActivity_fee_item,
    kActivity_activity_hint_item,
    kActivity_Num,
} ActivityItems;

static const int kLimitationRowHeight = 40.;

@implementation PreferDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configGallaryView];
    self.navigationItem.title = @"活动详情";
    self.tableView.scrollEnabled = NO;
}

- (void)configGallaryView {
    NSArray *images = [NSArray arrayWithObjects:[UIImage imageNamed:@"prefer_test_shop"],[UIImage imageNamed:@"user_info_bg"],[UIImage imageNamed:@"home_test_activity"], nil];
    ImageGallery *imageGallery = [[ImageGallery alloc] initWithImages:images];
    [self.gallaryView addSubview:imageGallery];
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 55;
}

- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 55)];
    view.backgroundColor = [UIColor colorWithRed:239/255. green:239/255. blue:244/255. alpha:1.];
    UILabel *hint = [[UILabel alloc] initWithFrame:CGRectMake(23, 0, [UIScreen mainScreen].bounds.size.width - 46, 55)];
    hint.textColor = [UIColor blackColor];
    hint.text = @"周杰伦2015演唱会随行小伙伴";
    hint.font = [UIFont systemFontOfSize:15.];
    [view addSubview:hint];
    
    self.heart = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 35, 10, 20, 20)];
    self.heart.image = [UIImage imageNamed:@"home_like"];
    [view addSubview:self.heart];
    
    self.likes = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 40, 30, 30, 15.)];
    self.likes.textColor = [UIColor grayColor];
    self.likes.font = [UIFont systemFontOfSize:11.];
    self.likes.textAlignment = NSTextAlignmentCenter;
    self.likes.text = @"26";
    [view addSubview:self.likes];
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if([indexPath row] == kActivity_activity_hint_item) {
        return 60;
    } else {
        return kLimitationRowHeight;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return kActivity_Num;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellIdentifier = @"HomeCellIdentifier";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    UIImageView *time = [[UIImageView alloc] initWithFrame:CGRectMake(23, 10, 20, 20)];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, [UIScreen mainScreen].bounds.size.width - 80, 40)];
    label.textColor = [UIColor grayColor];
    label.textAlignment = NSTextAlignmentLeft;
    label.font = [UIFont systemFontOfSize:15.];
    switch ([indexPath row]) {
        case kActivity_time_item:
            time.image = [UIImage imageNamed:@"home_time"];
            [cell addSubview:time];
            label.text = @"2015/11/28/19:00-2015/12/30/19:00";
            [cell addSubview:label];
            break;
        case kActivity_location_item:
            time.image = [UIImage imageNamed:@"home_location"];
            [cell addSubview:time];
            label.text = @"鸟巢体育馆";
            [cell addSubview:label];
            break;
        case kActivity_fee_item:
            time.image = [UIImage imageNamed:@"home_fee"];
            [cell addSubview:time];
            label.text = @"288元/人";
            [cell addSubview:label];
            break;
        case kActivity_activity_hint_item:
            cell.textLabel.text = @"周杰伦演唱会，真情邀请杰迷朋友一起来祝福，地点：鸟巢，水立方集合，希望准时";
            cell.textLabel.textColor = [UIColor grayColor];
            cell.textLabel.font = [UIFont systemFontOfSize:15.];
            break;
        default:
            break;
    }
    return cell;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    
    [super viewWillDisappear:animated];
}

@end
